import React from "react";
import { useRoutes, BrowserRouter } from "react-router-dom";
const Home = React.lazy(() => import("../pages/home"));
const Layout = React.lazy(() => import("../pages/layout"));
const Classify = React.lazy(() => import("../pages/classify"));
const Car = React.lazy(() => import("../pages/car"));
const My = React.lazy(() => import("../pages/my"));

const routes = [
  {
    path: "/",
    element: <Layout></Layout>,
    children: [
      {
        path: "/",
        element: <Home></Home>,
      },
      {
        path: "/classify",
        element: <Classify></Classify>,
      },
      {
        path: "/car",
        element: <Car></Car>,
      },
      {
        path: "/my",
        element: <My></My>,
      },
    ],
  },
];

const Index = () => {
  const App = () => {
    return useRoutes(routes);
  };
  return (
    <BrowserRouter>
      <App></App>
    </BrowserRouter>
  );
};

export default Index;
